<template>
  <!-- pdf/img 格式文件预览 -->
  <!-- 财务管理：电子回执单查看、发票预览 -->
  <div class="conten_box">
    <!-- <template v-if="urlType === 'pdf'"> -->
    <template v-if="pdfSource.url.endsWith('.pdf')">
      <vue-pdf-embed v-if="pdfSource.url" :source="pdfSource" style="max-width:800px;height:auto;margin:0 auto;" />
    </template>
    <template v-else>
      <img :src="pdfSource.url" style="max-width:800px;height:auto;margin:0 auto;" />
    </template>
  </div>
</template>
<script setup>
import { onMounted, ref, reactive } from 'vue'
import VuePdfEmbed from "vue-pdf-embed";

const props = defineProps({
  url: {
    type: String,
    default: ''
  }
})

const urlType = computed(() => {
  return props.url.split('.').pop()
})
const pdfSource = computed(() => {
  return {
    url: props.url,
    cMapUrl: "https://unpkg.com/pdfjs-dist@3.0.279/cmaps/",
    cMapPacked: true,
  }
})

</script>